package utils;

import java.util.Arrays;
import java.util.List;
import java.util.stream.Collectors;

public class Tools {
    public static List<Integer> listOf(int[] array) {
        return Arrays.stream(array).boxed().collect(Collectors.toList());
    }

    public static List<List<Integer>> listOf(int[][] array) {
        return Arrays.stream(array).map(
                ele -> Arrays.stream(ele).boxed().collect(Collectors.toList())
        ).collect(Collectors.toList());
    }

    public static <T> List<T> listOf(T element) {
        return Arrays.asList(element);
    }

    public static List<Object> listOf(Object ...obj) {
        return Arrays.stream(obj).collect(Collectors.toList());
    }

    public static int max(int[] arr) {
        int m = arr[0];
        for (int x : arr) {
            if(x > m) {
                m = x;
            }
        }
        return m;
    }

    public static void swap(int[] array, int i, int j) {
        int t = array[i];
        array[i] = array[j];
        array[j] = t;
    }

}
